package com.apes.fn.ssm.repository;

import com.apes.fn.ssm.model.StoreMemberModelsImport;
import com.apes.framework.jpa.repository.CustomRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Map;

public interface StoreMemberModelsImportRepository extends CustomRepository<StoreMemberModelsImport, String> {

    @Query(value = "" +
            "SELECT DISTINCT LOCATION_ID, " +
            "       (SELECT NAME FROM MAS_LOCATION J WHERE J.ID = A.LOCATION_ID) LOCATION_NAME, " +
            "       VIP_LIVENESS_ID, " +
            "       (SELECT COUNT(1) FROM STOCK_STORE_MEMBER_MODELS_I J WHERE J.LOCATION_ID = A.LOCATION_ID) ALL_VIP_LIVENE, " +
            "       (SELECT COUNT(1) FROM STOCK_STORE_MEMBER_MODELS_I J WHERE J.LOCATION_ID = A.LOCATION_ID AND J.VIP_LIVENESS_ID IN ('0', '5', '1')) ACTIVE_VIP " +
            "  FROM STOCK_STORE_MEMBER_MODELS_I A " +
            " WHERE 1 = 1 ", nativeQuery = true)
    List<Map> importVipSum();



}
